/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AdminMenu.java
 *
 * Created on 09 Oktober 2010, 9:22:31 PM
 */

package CAT200;
import java.util.*;
import java.sql.*;
/**
 *
 * @author Wai Hong
 */
public class AdminMenu extends javax.swing.JFrame {

    public String message, title, username;
    public ResultSet result;
    private Vector<Vector<String>> feedbackData;
    private Vector<String> feedbackDetail;

    private Vector<Vector<String>> memberData;
    private Vector<String> memberDetails;

    private Vector<Vector<String>> productData;
    private Vector<String> productDetail;

    /** Creates new form AdminMenu */
    public AdminMenu() {
        try
        {
            memberData = getMemberTable();
            memberDetails = new Vector<String>();
        	memberDetails.add("No.");
        	memberDetails.add("CUST_DATEOFJOIN");
        	memberDetails.add("CUST_USERNAME");
        	memberDetails.add("CUST_NAME");
        	memberDetails.add("CUST_IC");
        	memberDetails.add("CUST_TEL");
        	memberDetails.add("CUST_CITY");
        	memberDetails.add("CUST_STATE");
        	memberDetails.add("CUST_EMAIL");
        	memberDetails.add("BLACKLISTED");

        	//prepare for product table
        	productData = getProductTable();
        	productDetail = new Vector<String>();
       	    productDetail.add("No.");
       	    productDetail.add("P. Code");
       	    productDetail.add("DESCRIPTION");
       	    productDetail.add("QUANTITY");
       	    productDetail.add("PURCHASE PRICE");
       	    productDetail.add("PURCHASEDATE");


            feedbackData = getFeedbackTable();

            feedbackDetail = new Vector<String>();
            feedbackDetail.add("No.");
            feedbackDetail.add("Username");
            feedbackDetail.add("Title");
            feedbackDetail.add("Message");
            feedbackDetail.add("Date");
            initComponents();
            setLocationRelativeTo(null);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
        }
        catch(Exception e){ 
        	System.out.println("1 error: "+e);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        Mem_Table = new javax.swing.JTable();
        jLabel3 = new javax.swing.JLabel();
        Cust_TextField = new javax.swing.JTextField();
        Cus_Search = new javax.swing.JButton();
        geneReceiptButton = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        PRODUCT_TABLE = new javax.swing.JTable();
        P_DELETE = new javax.swing.JButton();
        P_ADD = new javax.swing.JButton();
        P_EDIT = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        Product_TextField = new javax.swing.JTextField();
        Product_Search = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        FEEDBACK_TABLE = new javax.swing.JTable();
        FEEDBACK_REPLY = new javax.swing.JButton();
        FEEDBACK_VIEW = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jButton10 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Administrator Menu", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 24))); // NOI18N

        Mem_Table.setModel(new javax.swing.table.DefaultTableModel(
            memberData, memberDetails)
    );
    Mem_Table.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            Mem_TableMouseClicked(evt);
        }
    });
    jScrollPane2.setViewportView(Mem_Table);

    jLabel3.setText("Search :");

    Cust_TextField.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Cust_TextFieldActionPerformed(evt);
        }
    });

    Cus_Search.setText("View");
    Cus_Search.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Cus_SearchActionPerformed(evt);
        }
    });

    geneReceiptButton.setText("Generate Receipt");
    geneReceiptButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            geneReceiptButtonActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(
        jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel2Layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 733, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addComponent(jLabel3)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(Cust_TextField, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(Cus_Search, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(geneReceiptButton)))
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    jPanel2Layout.setVerticalGroup(
        jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel2Layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 310, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel3)
                .addComponent(Cust_TextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(Cus_Search)
                .addComponent(geneReceiptButton))
            .addContainerGap(37, Short.MAX_VALUE))
    );

    jTabbedPane1.addTab("Member", jPanel2);

    jScrollPane1.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jScrollPane1MouseClicked(evt);
        }
    });

    PRODUCT_TABLE.setModel(new javax.swing.table.DefaultTableModel(
        productData, productDetail
    ));
    PRODUCT_TABLE.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            PRODUCT_TABLEMouseClicked(evt);
        }
    });
    jScrollPane1.setViewportView(PRODUCT_TABLE);

    P_DELETE.setText("Delete");
    P_DELETE.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            P_DELETEActionPerformed(evt);
        }
    });

    P_ADD.setText("Add");
    P_ADD.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            P_ADDActionPerformed(evt);
        }
    });

    P_EDIT.setText("Edit");
    P_EDIT.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            P_EDITActionPerformed(evt);
        }
    });

    jLabel4.setText("Search :");

    Product_TextField.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Product_TextFieldActionPerformed(evt);
        }
    });

    Product_Search.setText("View");
    Product_Search.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Product_SearchActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
    jPanel3.setLayout(jPanel3Layout);
    jPanel3Layout.setHorizontalGroup(
        jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 745, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLabel4)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(Product_TextField, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(Product_Search, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 237, Short.MAX_VALUE)
                    .addComponent(P_EDIT)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(P_ADD)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(P_DELETE)))
            .addContainerGap())
    );

    jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {P_ADD, P_DELETE, P_EDIT});

    jPanel3Layout.setVerticalGroup(
        jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 335, Short.MAX_VALUE)
            .addGap(18, 18, 18)
            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(P_DELETE)
                .addComponent(P_ADD)
                .addComponent(P_EDIT)
                .addComponent(jLabel4)
                .addComponent(Product_TextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(Product_Search))
            .addContainerGap())
    );

    jTabbedPane1.addTab("Product", jPanel3);

    FEEDBACK_TABLE.setModel(new javax.swing.table.DefaultTableModel(
        feedbackData, feedbackDetail
    ));
    jScrollPane3.setViewportView(FEEDBACK_TABLE);

    FEEDBACK_REPLY.setText("Reply");
    FEEDBACK_REPLY.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            FEEDBACK_REPLYActionPerformed(evt);
        }
    });

    FEEDBACK_VIEW.setText("View");
    FEEDBACK_VIEW.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            FEEDBACK_VIEWActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
    jPanel4.setLayout(jPanel4Layout);
    jPanel4Layout.setHorizontalGroup(
        jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel4Layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 733, Short.MAX_VALUE)
                    .addContainerGap())
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                    .addComponent(FEEDBACK_VIEW, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(FEEDBACK_REPLY)
                    .addGap(29, 29, 29))))
    );
    jPanel4Layout.setVerticalGroup(
        jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel4Layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 321, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(FEEDBACK_VIEW)
                .addComponent(FEEDBACK_REPLY))
            .addContainerGap(26, Short.MAX_VALUE))
    );

    jTabbedPane1.addTab("Feedback", jPanel4);

    jTextArea1.setColumns(20);
    jTextArea1.setLineWrap(true);
    jTextArea1.setRows(5);
    jTextArea1.setText("Terms and condition\n\nThe following describes the terms on which we offers you access to our services.\n\n________________________________________________________________________________\nIntroduction\n\nWelcome to OPS. By using OPS, you agree to the following terms with OPS Inc. and the general principles for the software of our subsidiaries and international affiliates. If you reside outside of Malaysia, you are contrating with one of our international OPS companies. If you have any questions, please refer to our help section.\n\nThis Agreement is effective on October 1, 2010, for current users, and upon acceptance for new users.\n\n_______________________________________________________________________________Scope\n\nBefore you become a member of OPS, you must read and accept all of the terms in, and linked to, this User Agreement and the OPS Privacy Policy. By accepting this User Agreement, you agree that this User Agreement and Privacy Policy will apply whenever you use OPS services. \n\n________________________________________________________________________________\nUsing OPS\n\nWhile using OPS services, you will not:\n- violate any laws, third party rights or our policies;\n- use our services if you are not able to form legally binding contracts, are under the age of 18, or are temporarily or indefinitely suspended from using our services;\n- manipulate the price of any item or interfere with other users' listings;\n- transfer your OPS account and User ID to another party without out consent;\n- distribute or post spam, unsolicited, or bulk electronic communications, chain letters, or pyramid schemes;\n- distribute viruses or any other technologies that may harm OPS, or the interests or property of OPS users;\n- copy, modify or distribute rights or content from the OPS or OPS's copyrights and trademarks;\n- harvest or otherwise collect information about users, including email addresses, without their consent.\n\n________________________________________________________________________________\nAbusing OPS\n\nOPS and the community work together to keep our services working properly and the community safe. Please report problems, offensive content, and policy violations to us.\n\nWithout limiting other remedies, we may limit, suspend or terminate our service and user accounts, prohibit access to our services and their content, delay or remove hosted content, and take technical and legal steps to keep users off the sites if we think that they are creating problems or possible legal liabilities, infringing the intellectual property rights of third parties, or acting inconsistently with the letter or spirit of our policies. Additionally, we may, in appropriate circumstances and at our discretion, suspend or terminate accounts of users who may be repeat infringers of intellectual property rights of third parties. We also reserve the right to cancel accounts that have been inactive for a long time, or to modify or discontinue OPS services.\n\n________________________________________________________________________________\nPrivacy\n\nWe do not sell or rent your personal information to third parties for their marketing purposes without your explicit consent. We use your information only as described in OPS Privacy Policy. We view protection of users' privacy as a very important community principle. We store and process your information on computers located in Malaysia that are protected by physical as well as technological security devices. You can access and modify the information you provide us and choose not to receive certain communications by signing-in to your account. If you object to your information being transferred or used in this way, please do not use out services.\n\n\n________________________________________________________________________________\nOPS Privacy Policy\n\nYou can browse our pages withour telling us who you are or revealing any personal information about yourself. Once you give us your personal information, you are not anonymous to us. If you choose to provide us with personal information, you consent to the transer and storage of that information on our servers located in Malaysia.\n\nWe may collect and store the following personal information:\n- email address, physical contact information;\n- transactional information based on your activities on the services;\n- other supplemental information from third parties (for example, if you incur a debt to OPS, we will generally conduct a credit check by obtaining additional information about you from a credit bureau, as permitted by law).\n\nWe don't sell or rent your personal information to third parties for their marketing purposes without your explicit consent. We may combine your information with information we collect from other companies and use it to improve and personalize our services, content and advertising.\n\nWe may disclose personal information to respond to legal requirements, enforce our policies, respond to clains that a listing or other content violates the rights of others, or protect anyone's rights, property, or safety. Such information will be disclosed in accordance with applicable laws and regulations.\n\nWe may also share your personal information with:\n- Members of the OPS Inc. -- like PayPal __ to joint content and services, to help detect and prevent potentially illegal acts and violations of our policies, and to guide decisions about their products, services and communications. Members of our corporate family will use this information to send you marketing communications only if you've requested their services.\n- Law enforcement or other governmental officials, in response to a verified request relating to a criminal investigation or alleged illegal activity. In such events, we will disclose information relevant to the investigation, such as name, city, state, zip code, telephone number, email address, User ID history, IP address, fraud complaints, and bidding and listing history.\n\nWithout limiting the above, in an effort to respect your privacy and our ability to keep the community free from bad actors, we will not otherwise disclose your personal information to law enforcement, other government officials, or other third parties without a subpoena, court order or substantially similar legal procedure, except when we believe in good faith that the disclosure of information is necessary to prevent imminent physical harm or financial loss or to report suspected illegal activity.\n\nYour password is the key to your account. Use unique numbers, letters and special characters, and do not disclose your eBay password to anyone. If you do share your password or your personal information with others, remember that you are responsible for all actions taken in the name of your account. If you lose control of your password, you may lose substantial control over your personal information and may be subject to legally binding actions taken on your behalf. Therefore, if your password has been compromised for any reason, you should immediately notify eBay and change your password. \n\nYour information is stored on our servers located in Malaysia. We treat data as an asset that must be protected and use lots of tools (encryption, passwords, physical security, etc.) to protect your personal information against unauthorized access and disclosure. However, as you probably know, third parties may unlawfully intercept or access transmissions or private communications, and other users may abuse or misuse your personal information that they collect from the site. Therefore, although we work very hard to protect your privacy, we do not promise, and you should not expect, that your personal information or private communications will always remain private. \n\n\n\n\n\n");
    jTextArea1.setWrapStyleWord(true);
    jScrollPane4.setViewportView(jTextArea1);

    jButton10.setText("Edit");

    javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
    jPanel5.setLayout(jPanel5Layout);
    jPanel5Layout.setHorizontalGroup(
        jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel5Layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 664, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addContainerGap(81, Short.MAX_VALUE))
    );
    jPanel5Layout.setVerticalGroup(
        jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel5Layout.createSequentialGroup()
            .addGap(16, 16, 16)
            .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 317, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(jButton10)
            .addContainerGap(26, Short.MAX_VALUE))
    );

    jTabbedPane1.addTab("Term and Condition", jPanel5);

    jButton4.setText("Exit");
    jButton4.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton4ActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jLabel1)
                .addComponent(jLabel2)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 765, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)))
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
            .addComponent(jLabel1)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(jLabel2)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 433, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(jButton4)
            .addContainerGap())
    );

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addContainerGap())
    );

    pack();
    }// </editor-fold>

    private void Cust_TextFieldActionPerformed(java.awt.event.ActionEvent evt) {                                            
        // TODO add your handling code here:
}                                           

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        //new First_Menu().show();
       
        System.exit(0);
}                                        

    private void FEEDBACK_REPLYActionPerformed(java.awt.event.ActionEvent evt) {                                               
        // TODO add your handling code here:
        try
        {
            DriverManager.registerDriver(new org.apache.derby.jdbc.ClientDriver());
            Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/CAT200-DB", "user", "123");

            Statement stmt = con.createStatement();
            ResultSet rsmt = stmt.executeQuery("select CUST_USERNAME from FEEDBACK order by FEEDBACK_NUM");

            for(int a = 0; a <= FEEDBACK_TABLE.getSelectedRow(); a++)
                rsmt.next();

            username = rsmt.getString("CUST_USERNAME");
            con.close();
            stmt.close();
            rsmt.close();
        }
        catch(Exception e){  }

        new Admin_Reply_Feedback(username).setVisible(true);
    }                                              

    private void FEEDBACK_VIEWActionPerformed(java.awt.event.ActionEvent evt) {                                              
        // TODO add your handling code here:
        try
        {
            DriverManager.registerDriver(new org.apache.derby.jdbc.ClientDriver());
            Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/CAT200-DB", "user", "123");

            Statement stmt = con.createStatement();
            ResultSet rsmt = stmt.executeQuery("select FEEDBACK_TITLE, MESSAGE from FEEDBACK order by FEEDBACK_NUM");

            for(int a = 0; a <= FEEDBACK_TABLE.getSelectedRow(); a++)
                rsmt.next();

            title = rsmt.getString("FEEDBACK_TITLE");
            message = rsmt.getString("MESSAGE");

            con.close();
            rsmt.close();
            stmt.close();
        }
        catch(Exception e){  }

        new ViewFeedback(title, message).setVisible(true);
    }                                             

    private void geneReceiptButtonActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    	
        new Generate_Receipt().setVisible(true);
    }

    private void Cus_SearchActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        new Customer_Profile(Cust_TextField.getText()).setVisible(true);
        this.dispose();
    }

    private void Mem_TableMouseClicked(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
        Object cust_id = Mem_Table.getValueAt(Mem_Table.getSelectedRow(), 2);
    	String s = cust_id.toString();
    	Cust_TextField.setText(s);
    }

    private void PRODUCT_TABLEMouseClicked(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
        Object prod_id = PRODUCT_TABLE.getValueAt(PRODUCT_TABLE.getSelectedRow(), 1);
    	String s = prod_id.toString();
    	Product_TextField.setText(s);
    }

    private void P_EDITActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        Object a = PRODUCT_TABLE.getValueAt(PRODUCT_TABLE.getSelectedRow(), 1);
    	String id = a.toString();
    	new Edit_Item(id).setVisible(true);
    	this.dispose();
    }

    private void P_ADDActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
            	new Add_New_Item().setVisible(true);
    	this.dispose();
    }

    private void P_DELETEActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        Object temp = PRODUCT_TABLE.getValueAt(PRODUCT_TABLE.getSelectedRow(), 1);
        String id = temp.toString();
        try
    	{
    	DriverManager.registerDriver(new org.apache.derby.jdbc.ClientDriver());
        Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/CAT200-DB", "user", "123");

        Statement stmt = con.createStatement();

        String Query = "DELETE FROM GALLERY WHERE PRODUCT_CODE = '"+id+"'";

        stmt.executeUpdate(Query);

        con.close();
        stmt.close();


    	}
    	catch(Exception e)
    	{
    	System.out.println("Delete data error: "+ e);
    	}

        this.dispose();
        new AdminMenu().setVisible(true);
    }

    private void Product_TextFieldActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:

    }

    private void Product_SearchActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        new View_Item(Product_TextField.getText()).setVisible(true);
        this.dispose();

    }

    private void jScrollPane1MouseClicked(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:

    }

    private Vector getMemberTable() throws Exception
    {
    	Vector<Vector<String>> table1 = new Vector<Vector<String>>();
    	DriverManager.registerDriver(new org.apache.derby.jdbc.ClientDriver());
        Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/CAT200-DB", "user", "123");

        Statement stmt = con.createStatement();
        result = stmt.executeQuery("select CUST_JOINDATE, CUST_USERNAME, CUST_NAME, CUST_IC,CUST_TEL,CUST_ADDRESS,CUST_POSTCODE,CUST_STATE,CUST_EMAIL,BLACKLISTED  from CUSTOMER order by CUST_JOINDATE");
        int i =1;
        while(result.next())
        {

        	Vector<String> table1Line = new Vector<String>();
        	String num = new Integer(i).toString();
            table1Line.addElement(num);
            table1Line.addElement(result.getString("CUST_JOINDATE"));
            table1Line.addElement(result.getString("CUST_USERNAME"));
            table1Line.addElement(result.getString("CUST_NAME"));
            table1Line.addElement(result.getString("CUST_IC"));
            table1Line.addElement(result.getString("CUST_TEL"));
            table1Line.addElement(result.getString("CUST_ADDRESS"));
            table1Line.addElement(result.getString("CUST_POSTCODE"));
            table1Line.addElement(result.getString("CUST_EMAIL"));
            table1Line.addElement(result.getString("BLACKLISTED"));

            table1.add(table1Line);
            i++;
        }

        con.close();
        stmt.close();

        return table1;
    }

    private Vector getProductTable() throws Exception
    {
    	Vector<Vector<String>> product = new Vector<Vector<String>>();
    	DriverManager.registerDriver(new org.apache.derby.jdbc.ClientDriver());
        Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/CAT200-DB", "user", "123");

        Statement stmt = con.createStatement();
        result = stmt.executeQuery("select PRODUCT_CODE, P_DESCRIPTION, P_QUANTITY, P_PRICE, P_INDATE, P_COLOR, P_SIZE, P_LOCATION from GALLERY ORDER BY PRODUCT_CODE ");

        int j =1;
        while(result.next())
        {
            Vector<String> productLine = new Vector<String>();
        	String num = new Integer(j).toString();
            productLine.addElement(num);
            productLine.addElement(result.getString("PRODUCT_CODE"));
            productLine.addElement(result.getString("P_DESCRIPTION"));
            productLine.addElement(result.getString("P_QUANTITY"));
            productLine.addElement(result.getString("P_PRICE"));
            productLine.addElement(result.getString("P_INDATE"));
            productLine.addElement(result.getString("P_COLOR"));
            productLine.addElement(result.getString("P_SIZE"));
            productLine.addElement(result.getString("P_LOCATION"));
            product.add(productLine);
            j++;
        }

    	return product;
    }

    private Vector getFeedbackTable()throws Exception
    {
        Vector<Vector<String>> feedback = new Vector<Vector<String>>();
        DriverManager.registerDriver(new org.apache.derby.jdbc.ClientDriver());
        Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/CAT200-DB", "user", "123");

        Statement stmt = con.createStatement();
        result = stmt.executeQuery("select FEEDBACK_NUM, FEEDBACK_DATE, FEEDBACK_TITLE, CUST_USERNAME, MESSAGE from FEEDBACK order by FEEDBACK_NUM");

        while(result.next())
        {
            Vector<String> feedbackLine = new Vector<String>();

            feedbackLine.addElement(result.getString("FEEDBACK_NUM"));
            feedbackLine.addElement(result.getString("CUST_USERNAME"));
            feedbackLine.addElement(result.getString("FEEDBACK_TITLE"));
            feedbackLine.addElement(result.getString("MESSAGE"));
            feedbackLine.addElement(result.getString("FEEDBACK_DATE"));
            feedback.add(feedbackLine);
        }

        con.close();
        stmt.close();
        return feedback;
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try
                {
                new AdminMenu().setVisible(true);
                }
                catch(Exception e){  }
            }
        });
    }

    // Variables declaration - do not modify
    private javax.swing.JButton Cus_Search;
    private javax.swing.JTextField Cust_TextField;
    private javax.swing.JButton FEEDBACK_REPLY;
    private javax.swing.JTable FEEDBACK_TABLE;
    private javax.swing.JButton FEEDBACK_VIEW;
    private javax.swing.JTable Mem_Table;
    private javax.swing.JTable PRODUCT_TABLE;
    private javax.swing.JButton P_ADD;
    private javax.swing.JButton P_DELETE;
    private javax.swing.JButton P_EDIT;
    private javax.swing.JButton Product_Search;
    private javax.swing.JTextField Product_TextField;
    private javax.swing.JButton geneReceiptButton;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextArea jTextArea1;
    // End of variables declaration

}
